import request from "@/utils/request";

// 商品类型接口
export interface GoodsType {
  id: number;
  typeName: string;
  createTime?: string;
  updateTime?: string;
  status?: number;
}

// 商品类型列表响应
export interface GoodsTypeListResponse {
  rows: GoodsType[];
  total: number;
}

// 商品信息接口
export interface GoodsInfo {
  id: number;
  name: string;
  price: number;
  typeId: number;
  typeName?: string;
  description?: string;
  detailImg?: string;
  headerImg?: string;
  status?: number;
  createTime?: string;
  updateTime?: string;
  usageMethod?: string;
  omsGoodsSkus?: Array<{
    id: number;
    skuName: string;
    price?: number;
  }>;
  omsGoodsInfos?: Array<GoodsInfo>;
}

// 商品列表响应
export interface GoodsListResponse {
  rows: GoodsInfo[];
  total: number;
}

// 商品列表请求参数
export interface GoodsListParams {
  status: string;
  noticeType: string;
  name?: string;
  typeId?: number;
  pageNum?: number;
  pageSize?: number;
}

// 商品详情接口
export interface GoodsDetailResponse {
  data: GoodsInfo;
}

// 获取商品类型列表
export function getGoodsTypeList() {
  return request<GoodsTypeListResponse>({
    url: "/goods/type/list",
    method: "GET",
  });
}

// 获取商品列表
export function getGoodsList(params: GoodsListParams) {
  return request<GoodsListResponse>({
    url: "/system/notice/list",
    method: "GET",
    data: params,
  });
}

// 商品详情
export function getGoodsDetail(id: number): Promise<GoodsDetailResponse> {
  return request<GoodsDetailResponse>({
    url: `/goods/info/${id}`,
    method: "GET",
  });
}

// 商品详情卡片
export function getGoodsDetailCard(
  userPhone: number
): Promise<GoodsDetailResponse> {
  return request<GoodsDetailResponse>({
    url: `/skin/solution/byReportId/${userPhone}`,
    method: "GET",
  });
}
